package com.zlm.TCP;

import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author 13026
 */
public class Server {
    /*
     * TCP 服务端接受数据
     * */
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10000);

        // 监听客户端连接
        Socket socket = ss.accept();
        InputStream is = socket.getInputStream();
        // 转换流，防止乱码
        InputStreamReader isr = new InputStreamReader(is);
        int b;
        while ((b = isr.read()) != -1) {
            System.out.print((char) b);
        }
        socket.close();
        ss.close();
    }
}
